/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-17
 * Time: 17:18
 */
//实现Runnable接口，基于匿名内部类
public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("这里是线程1");
                }
            }
        });

        t.start();

        while(true){
            Thread.sleep(1000);
            System.out.println("这里是主线程");
        }
    }
}
